home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / player2.1opus5 / arexx / PlayHifi.dopus5 < prev   
Text File  |  1995-09-23  |  9KB  |  292 lines

  1. /* Programm: PlayHifi.dopus5
  2. ** $VER: PlayHifi.dopus5 1.1 (25-Sep-95)
  3. ** 
  4. ** Needed: Directory Opus V5.xx (© by Jonathan Potter & GPSoftware)
  5. **         Play16 (© 1995 by Thomas Wenzel)
  6. **         mpega (© 1995 by Stephane Tavenard) or/and PeggyPlus MPEG-Card
  7. **         PlayADPCM (Autor Christian Buchner)
  8. **
  9. ** Copyright © 1995 Eckhard Ludwig (Eckhard@top.east.de)
  10. ** PlayHifi.dopus5 is copyrighted freeware. It may be distributed freely.
  11. **
  12. ** Call as:
  13. ** ------------------------------------------------------------------------------
  14. ** ARexx    DOpus5:ARexx/PlayHifi.dopus5 {Qp}
  15. ** ------------------------------------------------------------------------------
  16. ** Set all Attribut off.
  17. */
  18.  
  19. /*- Path to Player command --------------------------------------------*/
  20. Play16 = "C:Play16"
  21. PlayADPCM = "C:PlayADPCM"
  22. /*- Path to MPEGPlayer command ----------------------------------------*/
  23. PlayMPEG = "C:mpega"   /* Softwareplayer */
  24. MPEGA_OPTIONS=" -p -f0 -d2 -q2 "  /* edit options for your system ! */
  25. /*---------------------------------------------------------------------*/
  26.  
  27. Index  = 'T:PlayDOpus5Index.temp' /* Temporaere Titelliste */
  28. parse arg portname
  29. if portname='' then
  30.    portname='DOPUS.1'
  31. address value portname
  32.  
  33. options results
  34. options failat 21
  35. lf='0a'x
  36.  
  37. address command 'Delete >NIL: '||Index  /*falls Index in Benutzung, läuft Player bereits*/
  38.  
  39. if ~show('l','rexxsupport.library') then
  40.     call addlib('rexxsupport.library',0,-30,0)
  41.  
  42. /* init locale */
  43. if ~show(l,'locale.library') then
  44.         call addlib('locale.library',0,-30)
  45. if show(l,'locale.library') then
  46.         catalog=opencatalog('PlayHifi.catalog','english',0)
  47.  
  48. lister query source
  49. if rc>0 then do
  50.    dopus front
  51.    dopus request '"'getcatstr(0,'Error:'lf'No source selected')'"' getcatstr(1,'Quit')
  52.    exit
  53. end
  54.  
  55. parse var result handle 
  56.  
  57. lister query handle numselfiles
  58. if result=0 then do
  59.      dopus front
  60.      dopus request '"'getcatstr(2,'Error:'lf'No entry selected')'"' getcatstr(1,'Quit')
  61.      exit
  62. end
  63.  
  64. if exists(Index) then Index=Index||'1'
  65.    else Test2=1
  66.    
  67. if exists(Index) then call open('output',Index,'A')
  68.    else do
  69.       if open('output',Index,'w') ~=1 then do
  70.          dopus request '"'getcatstr(3,'Error:'lf'Load script in to editor and set path to Index !')'"' getcatstr(1,'Quit')
  71.          exit
  72.          end
  73.    end
  74.  
  75. lister set handle busy on
  76. lister query handle path
  77. QuellPfad=result
  78.  
  79. lister query handle selfiles stem files.
  80. lister set handle progress files.count getcatstr(4,'Scanning for Index...')
  81. lister refresh handle full  
  82.  
  83. do i=0 to files.count-1
  84.    lister query handle abort
  85.    if result then do
  86.     test=0
  87.     leave
  88.     end
  89.    lister set handle progress count i+1
  90.    lister set handle progress name files.i
  91.    Titel=Quellpfad||files.i
  92.    call DTTEST
  93.    if DT~=0 then do
  94.       lister query handle entry '"'files.i'"' stem fileinfo.
  95.       call writeln('output',Titel' @SIZE='fileinfo.size' @COMMENT='fileinfo.comment)
  96.       test=1
  97.       end
  98.    lister select handle '"'files.i'"' off
  99. end
  100. lister refresh handle full
  101. lister set handle busy off
  102. call close('output')
  103.  
  104. if Test2~=1 then do
  105.    if test=1 then do
  106.        dopus front 
  107.        dopus request '"'getcatstr(14,'Songs added to playlist')'"' 'OK'
  108.        end
  109.    exit
  110.    end
  111. if test ~=1 then do
  112.    address command 'Delete >NIL: '||Index
  113.    exit
  114.    end
  115.  
  116. lister new
  117. handle=result
  118. lister set handle title getcatstr(5,'Hifi Player')
  119. do forever
  120.  lister set handle sort date
  121.  call open('input2',Index,'R')
  122.  do i = 1 to 200
  123.    Zeile=readln('input2')
  124.    if Zeile="" then leave
  125.    SPOS=pos("@SIZE=",Zeile)
  126.    CPOS=pos("@COMMENT=",Zeile)
  127.    Titel=left(Zeile,SPOS-2)
  128.    if ~exists(Titel) then do
  129.      dopus front 
  130.      dopus request '"'getcatstr(8,'Error:'lf"'%s'"' not found !',Titel)'"' getcatstr(7,'Next')
  131.      iterate
  132.      end
  133.    call DTTEST
  134.    select
  135.     when DT="MP2" then MPEG=1
  136.     when DT="ADPCM3" then ADPCM=1
  137.     otherwise Play16DT=1
  138.    end
  139.    APOS=lastpos("/",Titel)
  140.    if APOS=0 then APOS=lastpos(":",Titel)   
  141.    songname=substr(Titel,APOS+1)
  142.    lister add handle '"'songname'" 'substr(Zeile,SPOS+6,CPOS-SPOS-6)' -1 'i' r 'substr(Zeile,CPOS+9)''
  143.    lister select handle '"'songname'"' on
  144.    lister set handle display name size comment
  145.  end
  146.  lister refresh handle full
  147.  call close ('input2')
  148.  
  149.  if MPEG=1 & ~show('P','Peggy') then do
  150.       if showlist("A","PEGGYPLUS")=1 then do
  151.         test=2
  152.         address command 'stack 8192'
  153.         address command 'RUN >NIL: <NIL: PEGGYPLUS:MPEGPlayer'
  154.         address command 'waitforport Peggy'
  155.         address value portname
  156.         dopus front
  157.         end
  158.       else do
  159.         if ~exists(PlayMPEG) then do
  160.           dopus front
  161.           dopus request '"'getcatstr(9,'Error:'lf'MPEG-Player not found !'lf'path to command: '"'%s'"'',PlayMPEG)'"' getcatstr(1,'Quit')
  162.       call Ende
  163.           end
  164.         end
  165.  end
  166.  if ADPCM=1 & ~exists(PlayADPCM) then do
  167.           dopus front
  168.           dopus request '"'getcatstr(10,'Error:'lf'ADPCM-Player not found !'lf'path to command: '"'%s'"'',PlayADPCM)'"' getcatstr(1,'Quit')
  169.       call Ende
  170.           end
  171.  if Play16DT=1 & ~exists(Play16) then do
  172.           dopus front
  173.           dopus request '"'getcatstr(11,'Error:'lf'Play16 not found !'lf'path to command: '"'%s'"'',Play16)'"' getcatstr(1,'Quit')
  174.       call Ende
  175.           end
  176.  
  177.  if open('input2',Index,'R') ~=1 then exit
  178.  lister set handle busy on
  179.  lister query handle selfiles stem files.
  180.  lister set handle progress files.count getcatstr(12,'Play sound ...')
  181.  lister refresh handle
  182.      
  183.  do i=0 to files.count-1
  184.    lister query handle abort
  185.    if result then leave
  186.    lister set handle progress count i+1
  187.    lister set handle progress name i+1"/"files.count"  "files.i
  188.    Zeile=readln('input2')
  189.    if Zeile="" then leave
  190.    Titel=left(Zeile,pos("@SIZE",Zeile)-2)
  191.    APOS=lastpos("/",Titel)
  192.    if APOS=0 then APOS=lastpos(":",Titel)   
  193.    songname=substr(Titel,APOS+1)
  194.    if songname ~=files.i then do
  195.     i=i-1
  196.     iterate
  197.     end
  198.    if ~exists(Titel) then do
  199.      dopus front 
  200.      dopus request '"'getcatstr(8,'Error:'lf"'%s'"' not found !',Titel)'"' getcatstr(7,'Next')
  201.      iterate
  202.      end
  203.    call DTTEST
  204.    select
  205.      when DT="MP2" then do
  206.          if show('P','Peggy') then do
  207.           address 'Peggy'
  208.           if MPEG=1 then do
  209.            open Titel
  210.            setwindow XOFF 0 YOFF 0 WIDTH 1 HEIGHT 1 XPIC 0 YPIC 0
  211.            Play
  212.            MPEG=2
  213.            end
  214.           else do
  215.            open Titel
  216.            Play async
  217.            Play wait
  218.            end
  219.        end
  220.        else address command PlayMPEG||MPEGA_OPTIONS||'"'Titel'"'
  221.      end
  222.    when DT="CDR" then address command Play16 '"'Titel'"' " RAW FREQ=44100 TRACKS=2 BITS=16 INTEL FAST Paula14c FILTER=OFF"
  223.    when DT="WAVE" then address command Play16 '"'Titel'"' " FAST Paula14c FILTER=OFF"
  224.    when DT="AIFF" then address command Play16 '"'Titel'"' " FAST Paula14c FILTER=OFF"
  225.    when DT="ADPCM3" then address command PlayADPCM '"'Titel'"' " NOFILTER"
  226.    otherwise address command Play16 '"'Titel'"' "FILTER=OFF"
  227.    end
  228.    address value portname
  229.    lister select handle '"'files.i'"' off
  230.    lister refresh handle
  231.  end
  232.  call close ('input2')
  233.  lister clear handle
  234.  lister clear handle progress
  235.  lister refresh handle
  236.  if exists(Index||'1') then do
  237.         address command 'Delete >NIL: '||Index
  238.         address command 'rename from 'Index||"1"' to 'Index
  239.         iterate
  240.         end
  241.       else leave
  242. end
  243.  
  244. Ende:
  245. address value portname
  246. lister set handle title
  247. lister refresh handle full
  248. lister set handle busy off
  249. lister close handle
  250.  
  251. if show('P','Peggy') & test=2 then do
  252.    address 'Peggy'
  253.    QUIT
  254.    end
  255. address command 'Delete >NIL: '||Index
  256. exit
  257. /*--------------------------------------------------------------------------------*/
  258.  
  259. DTTEST: /*Auf zulässige Sounddatei testen*/
  260. dopus getfiletype '"'Titel'"' id
  261. DT=result
  262. select
  263.   when DT="MP2" then return
  264.   when DT="ADPCM3" then return
  265.   when DT="CDR" then return
  266.   when DT="WAVE" then return
  267.   when DT="VOC" then return
  268.   when DT="AU" then return
  269.   when DT="MAUD" then return
  270.   when DT="AIFF" then return
  271.   when DT="8SVX" then return
  272.   otherwise do
  273.      if DT='RESULT' then DT=getcatstr(13,'not identificed')
  274.      dopus front 
  275.       dopus request '"'getcatstr(6,'Error:'lf'The file '"'%s'"' is filetype '"'%s'"lf'Format not supported !',files.i,DT)'"' getcatstr(7,'Next')
  276.      DT=0
  277.      end
  278. end
  279. return DT
  280.  
  281. /*--------------------------------------------------------------------------------*/
  282. getcatstr:
  283.    parse arg msgno,msgstring,insert.1,insert.2
  284.    if catalog~=0 then msgstring=getcatalogstr(catalog,msgno,msgstring)
  285.    j=0
  286.    do while pos('%s',msgstring)>0
  287.       parse var msgstring fore '%s' aft
  288.       j=j+1
  289.       msgstring=fore||insert.j||aft
  290.       end
  291.    return msgstring
  292.